package com.lgw.coupon.mapper;

import com.lgw.commons.model.pojo.VoucherOrders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface VoucherOrdersMapper {
    @Select("select id, order_no, voucher_id, customer_id, " +
            " status, seckill_id, create_date, update_date, " +
            " is_valid from voucher_orders where customer_id = #{customerId} " +
            " and voucher_id = #{voucherId} and is_valid = 1 and status between 0 and 1 ")
    VoucherOrders findCustomerOrder(@Param("customerId")Integer customerId, @Param("voucherId")Integer voucherId);

    @Insert("insert into voucher_orders (order_no, voucher_id, customer_id, " +
            " status, seckill_id,  create_date, update_date,  is_valid)" +
            " values (#{orderNo}, #{voucherId}, #{customerId}, #{status}, #{seckillId}, " +
            " now(), now(), 1)")
    long save(VoucherOrders voucherOrders);
}
